import csv

def main():
    # 解析输入，只分割第一个空格
    data = input().split(' ', 1)
    query_type = data[0]
    query_value = data[1].strip()

    # 初始化计数器
    count = 0
    
    # 读取CSV文件
    with open('directory.csv', 'r', encoding='utf-8') as file:
        reader = csv.DictReader(file)
        
        # 根据查询类型筛选数据
        for row in reader:
            if query_type == '1':  # 按国家查询
                if row.get('Country', '').strip() == query_value:
                    count += 1
            elif query_type == '2':  # 按城市查询
                if row.get('City', '').strip() == query_value:
                    count += 1
    
    # 输出结果
    print(count)

if __name__ == "__main__":
    main()
